/**
 * 
 */
package com.rapwaves.feeds;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.IsSerializable;
import com.google.gwt.user.client.ui.Widget;
import com.rapwaves.feeds.action.FeedActionEngine;
import com.rapwaves.feeds.action.FeedActions;
import com.rapwaves.feeds.content.FeedContentEngine;
import com.rapwaves.feeds.content.FeedContents;
import com.rapwaves.feeds.widgets.FeedItemUI;
import com.rapwaves.feeds.widgets.FeedsUI;

/**
 * @author asanthan
 * 
 */
public class FeedEngine implements IsSerializable {

	public FeedEngine() {
		super();
		// TODO Auto-generated constructor stub
	}

	public static Widget getWidget(Feeds feeds) {
		FeedsUI feedsUI = GWT.create(FeedsUI.class);
		if (feeds != null) {
			for (FeedItem feedItem : feeds) {
				feedsUI.addFeedItem(getWidget(feedItem));
			}
		}
		return feedsUI;
	}

	public static Widget getWidget(FeedItem feedItem) {
		FeedItemUI feedItemUI = new FeedItemUI(feedItem);
		feedItemUI.addFeedContents(getWidget(feedItem.getFeedContents()));
		// TODO: Add feed action here.
		return feedItemUI;
	}

	public static Widget getWidget(FeedContents feedContents) {
		return FeedContentEngine.getWidget(feedContents);
	}

	private static Widget getWidget(FeedActions feedActionList) {
		return FeedActionEngine.getWidget(feedActionList);
	}
}
